#############################
## BLIS/Swayable: Figure 2 ##
#############################

# File Description: 
# Uses data/packages from O_Data.R
# Replicates Figure 2 from Fabric of Repair report (2025)
# Date Last Updated: 2 May 2025

#############################

# Creating a summary dataframe of baseline Reparations support by political party
baseline_party_reparations <- 
  df %>% 
  group_by(race, summarized_party) %>% 
  count(rep_baseline_categorical) %>% 
  mutate(Percentage = n/sum(n) * 100) %>% 
  rename(baseline_support = rep_baseline_categorical) %>% 
  add_column(Movement = "Reparations")

# Creating a summary dataframe of baseline Land Back support by political party
baseline_party_landback <- 
  df %>% 
  group_by(race, summarized_party) %>% 
  count(landback_baseline_categorical) %>% 
  mutate(Percentage = n/sum(n) * 100) %>% 
  rename(baseline_support = landback_baseline_categorical) %>% 
  add_column(Movement = "Land Back")

# Combining both Reparations and Land Back dataframes
baseline_party <- bind_rows(baseline_party_reparations, baseline_party_landback)

# Plotting Figure 2
baseline_party %>% 
  ggplot(aes(x = summarized_party, y = Percentage, fill = baseline_support)) +
  geom_bar(stat = "identity") +
  labs(title = "Baseline Support by Partisanship",
       x = "Partisanship",
       y = "Percentage",
       fill = "Support") +
  scale_y_continuous(labels = scales::percent_format(scale = 1)) +
  facet_grid(vars(Movement), vars(race)) + 
  theme(axis.text.x = element_text(angle = 45)) +
  scale_fill_manual(values = c('#F6A40E', '#F35018', '#5AAE7D')) + 
  theme_bw() 
